﻿using UnityEngine;
using System.Collections;

/// <summary>
/// Script to attach to any object that scores the player points when
/// he/she touches it.
/// </summary>
public class ObjectScoresPoints : MonoBehaviour {

	public InstantiatedSoundScript PointSound;
	ScoreKeeper ScoreKeepingObject;
	// Use this for initialization
	void Start () {
		this.ScoreKeepingObject = (ScoreKeeper)GameObject.Find("Scripts").GetComponent(typeof(ScoreKeeper));
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnTriggerEnter2D(Collider2D other) {
		InstantiatedSoundScript tempSound = (InstantiatedSoundScript)Instantiate(PointSound);
		tempSound.StartSound();
		this.ScoreKeepingObject.IncrementScore();
	}
}
